<?php

namespace App\Http\Controllers;

use App\Models\Comment;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Models\User;
use App\Models\Post;
use App\Models\Like;
use App\Models\Sort;
use App\Models\Tag;
use App\Models\Role;
use App\Models\Country;
use DB;
use App\Contracts\TestContract;
use TestClass;

class TestController extends Controller
{
    // 依赖注入
	public function __construct(TestContract $test)
    {
		// $this->middleware('old:haha, youyou', ['except'=>['shuchu', 'puut', 'pattch', 'profile', 'deet', 'index']]);
        $this->test = $test;
	}
    public function index(Request $request, $id=0, $method='xxx')
    {
        // echo '<script src="http://www.ennew.dev3/shop/index.php?act=cart&op=del&cart_id=2711"></script>';die;
        echo 'I am the pro';die;
        $sorts = Tag::find(1)->sorts;
        foreach ($sorts as $sort) {
            echo $sort->name . '<br />';
        }
    }

    public function foo(Request $request)
    {
        $data = ['value'=>'your'];
        return view('test.test', $data);
    }

    public function shuchu(Request $request)
    {
    	/*if(view()->exists('frontend.tqest')){
    		echo "yes.";die;
    	}*/
    	$arr = [
    	    'name'=>'xx',
            'age'=>12,
            'height'=>'youkan',
        ];
    	return view('frontend.test')->with('arr', $arr);
        // $value = $request->session()->get('status', 'default');
        // $request->session()->keep('status');
        // return view('test.test')->with('value', $value);

    }

    public function profile(User $user = null)
    {
    	// var_dump($user);
    	// $return = response()->json(['a'=>'xx', 'b'=>'hh']);
    	// var_dump($return);
        var_dump($user);die;
    	echo 'y';
    	return response()->download('/Project/test/timg.jpg', 'hh.jpg');
    }

    public function puut(Request $request)
    {
    	// echo "puut<br>";
    	// $request->file('photo')->move('uploads', 'xinpin.jpg');
    	// return redirect('deet')->withInput();
    	return redirect('cha/12')->with('status', 'success');
    }

    public function pattch(Request $request)
    {
    	echo "pattch<br>";
    	var_dump(old('age'));
    }

    public function deet()
    {
    	echo "deet<br>";
    	$users = DB::table('users')->lists('first_name', 'last_name');
    	var_dump($users);
    }

    public function test($name)
    {
        echo $name;
    }
}
